home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / util / gnu / emacs_src_18_58.lha / emacs-18.58 / src / keymap.c < prev    next >
C/C++ Source or Header  |  1992-04-26  |  34KB  |  1,334 lines

  1. /* Manipulation of keymaps
  2.    Copyright (C) 1985, 1986, 1987, 1988, 1990 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU Emacs.
  5.  
  6. GNU Emacs is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GNU Emacs is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU Emacs; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21. #include "config.h"
  22. #include <stdio.h>
  23. #undef NULL
  24. #include "lisp.h"
  25. #include "commands.h"
  26. #include "buffer.h"
  27.  
  28. #define min(a, b) ((a) < (b) ? (a) : (b))
  29.  
  30. /* Actually allocate storage for these variables */
  31.  
  32. #ifdef AMIGA
  33. #define HAVE_X_WINDOWS        /* We want the mouse map too */
  34. #endif
  35.  
  36. #ifdef HAVE_X_WINDOWS
  37. Lisp_Object MouseMap;        /* Keymap for mouse commands */
  38. #endif /* HAVE_X_WINDOWS */
  39.  
  40. Lisp_Object global_map;
  41.  
  42. Lisp_Object Vglobal_map;
  43.  
  44. Lisp_Object Vesc_map;
  45.  
  46. Lisp_Object Vctl_x_map;
  47.  
  48. /* Keymap used for minibuffers with self-inserting space.  */
  49. Lisp_Object Vminibuffer_local_map;
  50.  
  51. /* Keymap used for minibuffers when space does not self insert.  */
  52. Lisp_Object Vminibuffer_local_ns_map;            
  53.  
  54. /* Keymap used for minibuffers when doing completion */
  55. Lisp_Object Vminibuffer_local_completion_map;
  56.  
  57. /* Keymap used for minibuffers when doing completion and require a match */
  58. Lisp_Object Vminibuffer_local_must_match_map;
  59.  
  60. Lisp_Object Qkeymapp, Qkeymap;
  61.  
  62. /* A char over 0200 in a key sequence
  63.    is equivalent to prefixing with this character.  */
  64.  
  65. extern int meta_prefix_char;
  66.  
  67. static void insert_first_line ();
  68.  
  69. DEFUN ("make-keymap", Fmake_keymap, Smake_keymap, 0, 0, 0,
  70.   "Construct and return a new keymap, a vector of length 128.\n\
  71. All entries in it are nil, meaning \"command undefined\".")
  72.   ()
  73. {
  74.   register Lisp_Object val;
  75.   XFASTINT (val) = 0200;
  76.   return Fmake_vector (val, Qnil);
  77. }
  78.  
  79. DEFUN ("make-sparse-keymap", Fmake_sparse_keymap, Smake_sparse_keymap, 0, 0, 0,
  80.   "Construct and return a new sparse-keymap list.\n\
  81. Its car is 'keymap and its cdr is an alist of (CHAR . DEFINITION).\n\
  82. Initially the alist is nil.")
  83.   ()
  84. {
  85.   return Fcons (Qkeymap, Qnil);
  86. }
  87.  
  88. /* Install a standard key binding at initialization time.
  89.    For example,
  90.      ndefkey (Vctl_x_map, Ctl ('X'), "exchange-point-and-mark");  */
  91.  
  92. void
  93. ndefkey (keymap, key, defname)
  94.      Lisp_Object keymap;
  95.      int key;
  96.      char *defname;
  97. {
  98.   store_in_keymap (keymap, key, intern (defname));
  99. }
  100.  
  101. /* Define character fromchar in map frommap as an alias for character tochar in map tomap.
  102.  Subsequent redefinitions of the latter WILL affect the former. */
  103.  
  104. #ifdef NOTDEF
  105. void
  106. synkey (frommap, fromchar, tomap, tochar)
  107.      struct Lisp_Vector *frommap, *tomap;
  108.      int fromchar, tochar;
  109. {
  110.   Lisp_Object v, c;
  111.   XSET (v, Lisp_Vector, tomap);
  112.   XFASTINT (c) = tochar;
  113.   frommap->contents[fromchar] = Fcons (v, c);
  114. }
  115. #endif /* NOTDEF */
  116.  
  117. DEFUN ("keymapp", Fkeymapp, Skeymapp, 1, 1, 0,
  118.   "Return t if ARG is a keymap.\n\
  119. A keymap is a vector of length 128, or a list (keymap . ALIST),\n\
  120. where alist elements look like (CHAR . DEFN).\n\
  121. A symbol whose function definition is a keymap is itself a keymap.")
  122.   (object)
  123.      Lisp_Object object;
  124. {
  125.   register Lisp_Object tem;
  126.   tem = object;
  127.   while (XTYPE (tem) == Lisp_Symbol)
  128.     {
  129.       tem = XSYMBOL (tem)->function;
  130.       if (EQ (tem, Qunbound))
  131.     return Qnil;
  132.       QUIT;
  133.     }
  134.  
  135.   if ((XTYPE (tem) == Lisp_Vector && XVECTOR (tem)->size == 0200)
  136.       || (CONSP (tem) && EQ (XCONS (tem)->car, Qkeymap)))
  137.     return Qt;
  138.   return Qnil;
  139. }
  140.  
  141. Lisp_Object
  142. get_keymap_1 (object, error)
  143.      Lisp_Object object;
  144.      int error;
  145. {
  146.   register Lisp_Object tem;
  147.  
  148.   while (1)
  149.     {
  150.       tem = object;
  151.       while (XTYPE (tem) == Lisp_Symbol && !EQ (tem, Qunbound))
  152.     {
  153.       tem = XSYMBOL (tem)->function;
  154.       QUIT;
  155.     }
  156.       if ((XTYPE (tem) == Lisp_Vector && XVECTOR (tem)->size == 0200)
  157.       || (CONSP (tem) && EQ (XCONS (tem)->car, Qkeymap)))
  158.     return tem;
  159.       if (error)
  160.     object = wrong_type_argument (Qkeymapp, object);
  161.       else return Qnil;
  162.     }
  163. }
  164.  
  165. Lisp_Object
  166. get_keymap (object)
  167.      Lisp_Object object;
  168. {
  169.   return get_keymap_1 (object, 1);
  170. }
  171.  
  172. Lisp_Object
  173. get_keyelt (object)
  174.      register Lisp_Object object;
  175. {
  176.   register Lisp_Object map, tem;
  177.  
  178.   while (map = get_keymap_1 (Fcar_safe (object), 0),
  179.      tem = Fkeymapp (map),
  180.      !NULL (tem))
  181.       /*(XTYPE (object) == Lisp_Cons && !EQ (XCONS (object)->car, Qkeymap))*/
  182.     {
  183.       object = Fcdr (object);
  184.       if (CONSP (map))
  185.     object = Fcdr (Fassq (object, Fcdr (map)));
  186.       else
  187.     object = Faref (map, object);
  188.     }
  189.   return object;
  190. }
  191.  
  192. Lisp_Object
  193. access_keymap (map, idx)
  194.      Lisp_Object map;
  195.      register int idx;
  196. {
  197.   register Lisp_Object val;
  198.   if (idx < 0 || idx >= 0200)
  199.     error ("Command key out of range 0-127");
  200.  
  201.   /* Get definition for character `idx' proper.  */
  202.   if (CONSP (map))
  203.     val = Fcdr (Fassq (make_number (idx), Fcdr (map)));
  204.   else
  205.     val = XVECTOR (map)->contents[idx];
  206.  
  207.   return val;
  208. }
  209.  
  210. Lisp_Object
  211. store_in_keymap (keymap, idx, def)
  212.      Lisp_Object keymap;
  213.      register int idx;
  214.      register Lisp_Object def;
  215. {
  216.   register Lisp_Object tem;
  217.  
  218.   if (idx < 0 || idx >= 0200)
  219.     error ("Command key out of range 0-127");
  220.  
  221.   if (CONSP (keymap))
  222.     {
  223.       tem = Fassq (make_number (idx), Fcdr (keymap));
  224.       if (!NULL (tem))
  225.     Fsetcdr (tem, def);
  226.       else
  227.     Fsetcdr (keymap, Fcons (Fcons (make_number (idx), def),
  228.                 Fcdr (keymap)));
  229.     }
  230.   else
  231.     XVECTOR (keymap)->contents[idx] = def;
  232.  
  233.   return def;
  234. }
  235.  
  236. DEFUN ("copy-keymap", Fcopy_keymap, Scopy_keymap, 1, 1, 0,
  237.   "Return a copy of the keymap KEYMAP.\n\
  238. The copy starts out with the same definitions of KEYMAP,\n\
  239. but changing either the copy or KEYMAP does not affect the other.\n\
  240. Any key definitions that are subkeymaps are recursively copied.\n\
  241. However, a key definition which is a symbol whose definition is a keymap\n\
  242. is not copied.")
  243.   (keymap)
  244.      Lisp_Object keymap;
  245. {
  246.   register Lisp_Object copy, tem;
  247.  
  248.   keymap = get_keymap (keymap);
  249.   if (XTYPE (keymap) == Lisp_Vector)
  250.     {
  251.       register int i;
  252.       copy = Fcopy_sequence (keymap);
  253.       for (i = 0; i < XVECTOR (copy)->size; i++)
  254.     if (XTYPE (XVECTOR (copy)->contents[i]) != Lisp_Symbol)
  255.       if (tem = Fkeymapp (XVECTOR (copy)->contents[i]), !NULL (tem))
  256.         XVECTOR (copy)->contents[i]
  257.           = Fcopy_keymap (XVECTOR (copy)->contents[i]);
  258.     }
  259.   else
  260.     {
  261.       register Lisp_Object tail;
  262.       copy = Fcopy_alist (keymap); 
  263.       for (tail = copy; CONSP (tail); tail = XCONS (tail)->cdr)
  264.     {
  265.       register Lisp_Object elt;
  266.       elt = XCONS (tail)->car;
  267.       if (CONSP (elt)
  268.           && XTYPE (XCONS (elt)->cdr) != Lisp_Symbol
  269.           && (tem = Fkeymapp (XCONS (elt)->cdr), !NULL (tem)))
  270.         XCONS (elt)->cdr = Fcopy_keymap (XCONS (elt)->cdr);
  271.     }
  272.     }
  273.   return copy;
  274. }
  275.  
  276. DEFUN ("define-key", Fdefine_key, Sdefine_key, 3, 3, 0,
  277.   "Args KEYMAP, KEY, DEF.  Define key sequence KEY, in KEYMAP, as DEF.\n\
  278. KEYMAP is a keymap.  KEY is a string meaning a sequence of keystrokes.\n\
  279. DEF is anything that can be a key's definition:\n\
  280.  nil (means key is undefined in this keymap),\n\
  281.  a command (a Lisp function suitable for interactive calling)\n\
  282.  a string (treated as a keyboard macro),\n\
  283.  a keymap (to define a prefix key),\n\
  284.  a list (KEYMAP . CHAR), meaning use definition of CHAR in map KEYMAP,\n\
  285.  or a symbol.  The symbol's function definition is used as the key's\n\
  286. definition, and may be any of the above (including another symbol).")
  287.   (keymap, key, def)
  288.      register Lisp_Object keymap;
  289.      Lisp_Object key;
  290.      Lisp_Object def;
  291. {
  292.   register int idx;
  293.   register int c;
  294.   register Lisp_Object tem;
  295.   register Lisp_Object cmd;
  296.   int metized = 0;
  297.  
  298.   keymap = get_keymap (keymap);
  299.  
  300.   CHECK_STRING (key, 1);
  301.   if (XSTRING (key)->size == 0)
  302.     return Qnil;
  303.  
  304.   idx = 0;
  305.   while (1)
  306.     {
  307.       c = XSTRING (key)->data[idx];
  308.       if (c >= 0200 && !metized)
  309.     {
  310.       c = meta_prefix_char;
  311.       metized = 1;
  312.     }
  313.       else
  314.     {
  315.       c &= 0177;
  316.       metized = 0;
  317.       idx++;
  318.     }
  319.  
  320.       if (idx == XSTRING (key)->size)
  321.     return store_in_keymap (keymap, c, def);
  322.  
  323.       cmd = get_keyelt (access_keymap (keymap, c));
  324.       if (NULL (cmd))
  325.     {
  326.       cmd = Fmake_sparse_keymap ();
  327.       store_in_keymap (keymap, c, cmd);
  328.     }
  329.       tem = Fkeymapp (cmd);
  330.       if (NULL (tem))
  331.     error ("Key sequence %s uses invalid prefix characters",
  332.            XSTRING (key)->data);
  333.  
  334.       keymap = get_keymap (cmd);
  335.     }
  336. }
  337.  
  338. /* Value is number if KEY is too long; nil if valid but has no definition. */
  339.  
  340. DEFUN ("lookup-key", Flookup_key, Slookup_key, 2, 2, 0,
  341.   "In keymap KEYMAP, look up key sequence KEY.  Return the definition.\n\
  342. nil means undefined.  See doc of define-key for kinds of definitions.\n\
  343. Number as value means KEY is \"too long\";\n\
  344. that is, characters in it except for the last one\n\
  345. fail to be a valid sequence of prefix characters in KEYMAP.\n\
  346. The number is how many characters at the front of KEY\n\
  347. it takes to reach a non-prefix command.")
  348.   (keymap, key)
  349.      register Lisp_Object keymap;
  350.      Lisp_Object key;
  351. {
  352.   register int idx;
  353.   register Lisp_Object tem;
  354.   register Lisp_Object cmd;
  355.   register int c;
  356.   int metized = 0;
  357.  
  358.   keymap = get_keymap (keymap);
  359.  
  360.   CHECK_STRING (key, 1);
  361.   if (XSTRING (key)->size == 0)
  362.     return Qnil;
  363.  
  364.   idx = 0;
  365.   while (1)
  366.     {
  367.       c = XSTRING (key)->data[idx];
  368.       if (c >= 0200 && !metized)
  369.     {
  370.       c = meta_prefix_char;
  371.       metized = 1;
  372.     }
  373.       else
  374.     {
  375.       c &= 0177;
  376.       metized = 0;
  377.       idx++;
  378.     }
  379.  
  380.       cmd = get_keyelt (access_keymap (keymap, c));
  381.       if (idx == XSTRING (key)->size)
  382.     return cmd;
  383.  
  384.       tem = Fkeymapp (cmd);
  385.       if (NULL (tem))
  386.     return make_number (idx);
  387.  
  388.       keymap = get_keymap (cmd);
  389.       QUIT;
  390.     }
  391. }
  392.  
  393. DEFUN ("key-binding", Fkey_binding, Skey_binding, 1, 1, 0,
  394.   "Return the definition for command KEYS in current keymaps.\n\
  395. KEYS is a string, a sequence of keystrokes.\n\
  396. The definition is probably a symbol with a function definition.")
  397.   (keys)
  398.      Lisp_Object keys;
  399. {
  400.   register Lisp_Object map, value, value1;
  401.   map = current_buffer->keymap;
  402.   if (!NULL (map))
  403.     {
  404.       value = Flookup_key (map, keys);
  405.       if (NULL (value))
  406.     {
  407.       XSET (map, Lisp_Vector, global_map);
  408.       value1 = Flookup_key (map, keys);
  409.       if (XTYPE (value1) == Lisp_Int)
  410.         return Qnil;
  411.       return value1;
  412.     }
  413.       else if (XTYPE (value) != Lisp_Int)
  414.     return value;
  415.     }
  416.   XSET (map, Lisp_Vector, global_map);
  417.   return Flookup_key (map, keys);
  418. }
  419.  
  420. DEFUN ("local-key-binding", Flocal_key_binding, Slocal_key_binding, 1, 1, 0,
  421.   "Return the definition for command KEYS in current local keymap only.\n\
  422. KEYS is a string, a sequence of keystrokes.\n\
  423. The definition is probably a symbol with a function definition.")
  424.   (keys)
  425.      Lisp_Object keys;
  426. {
  427.   register Lisp_Object map;
  428.   map = current_buffer->keymap;
  429.   if (NULL (map))
  430.     return Qnil;
  431.   return Flookup_key (map, keys);
  432. }
  433.  
  434. DEFUN ("global-key-binding", Fglobal_key_binding, Sglobal_key_binding, 1, 1, 0,
  435.   "Return the definition for command KEYS in current global keymap only.\n\
  436. KEYS is a string, a sequence of keystrokes.\n\
  437. The definition is probably a symbol with a function definition.")
  438.   (keys)
  439.      Lisp_Object keys;
  440. {
  441.   register Lisp_Object map;
  442.   XSET (map, Lisp_Vector, global_map);
  443.   return Flookup_key (map, keys);
  444. }
  445.  
  446. DEFUN ("global-set-key", Fglobal_set_key, Sglobal_set_key, 2, 2,
  447.   "kSet key globally: \nCSet key %s to command: ",
  448.   "Give KEY a definition of COMMAND.\n\
  449. COMMAND is a symbol naming an interactively-callable function.\n\
  450. KEY is a string representing a sequence of keystrokes.\n\
  451. Note that if KEY has a local definition in the current buffer\n\
  452. that local definition will continue to shadow any global definition.")
  453.   (keys, function)
  454.      Lisp_Object keys, function;
  455. {
  456.   register Lisp_Object map;
  457.   XSET (map, Lisp_Vector, global_map);
  458.   CHECK_STRING (keys, 1);
  459.   Fdefine_key (map, keys, function);
  460.   return Qnil;
  461. }
  462.  
  463. DEFUN ("local-set-key", Flocal_set_key, Slocal_set_key, 2, 2,
  464.   "kSet key locally: \nCSet key %s locally to command: ",
  465.   "Give KEY a local definition of COMMAND.\n\
  466. COMMAND is a symbol naming an interactively-callable function.\n\
  467. KEY is a string representing a sequence of keystrokes.\n\
  468. The definition goes in the current buffer's local map,\n\
  469. which is shared with other buffers in the same major mode.")
  470.   (keys, function)
  471.      Lisp_Object keys, function;
  472. {
  473.   register Lisp_Object map;
  474.   map = current_buffer->keymap;
  475.   if (NULL (map))
  476.     {
  477.       map = Fmake_sparse_keymap ();
  478.       current_buffer->keymap = map;
  479.     }
  480.  
  481.   CHECK_STRING (keys, 1);
  482.   Fdefine_key (map, keys, function);
  483.   return Qnil;
  484. }
  485.  
  486. DEFUN ("global-unset-key", Fglobal_unset_key, Sglobal_unset_key,
  487.   1, 1, "kUnset key globally: ",
  488.   "Remove global definition of KEY.\n\
  489. KEY is a string representing a sequence of keystrokes.")
  490.   (keys)
  491.      Lisp_Object keys;
  492. {
  493.   return Fglobal_set_key (keys, Qnil);
  494. }
  495.  
  496. DEFUN ("local-unset-key", Flocal_unset_key, Slocal_unset_key, 1, 1,
  497.   "kUnset key locally: ",
  498.   "Remove local definition of KEY.\n\
  499. KEY is a string representing a sequence of keystrokes.")
  500.   (keys)
  501.      Lisp_Object keys;
  502. {
  503.   if (!NULL (current_buffer->keymap))
  504.     Flocal_set_key (keys, Qnil);
  505.   return Qnil;
  506. }
  507.  
  508. DEFUN ("define-prefix-command", Fdefine_prefix_command, Sdefine_prefix_command, 1, 1, 0,
  509.   "Define SYMBOL as a prefix command.\n\
  510. A keymap is created and stored as SYMBOL's function definition.")
  511.   (name)
  512.      Lisp_Object name;
  513. {
  514.   Ffset (name, Fmake_keymap ());
  515.   return name;
  516. }
  517.  
  518. DEFUN ("use-global-map", Fuse_global_map, Suse_global_map, 1, 1, 0,
  519.   "Selects KEYMAP as the global keymap.")
  520.   (keymap)
  521.      Lisp_Object keymap;
  522. {
  523.   keymap = get_keymap (keymap);
  524.   CHECK_VECTOR (keymap, 0);
  525.   global_map = keymap;
  526.   return Qnil;
  527. }
  528.  
  529. DEFUN ("use-local-map", Fuse_local_map, Suse_local_map, 1, 1, 0,
  530.   "Selects KEYMAP as the local keymap.\n\
  531. nil for KEYMAP means no local keymap.")
  532.   (keymap)
  533.      Lisp_Object keymap;
  534. {
  535.   if (!NULL (keymap))
  536.     keymap = get_keymap (keymap);
  537.  
  538.   current_buffer->keymap = keymap;
  539.  
  540.   return Qnil;
  541. }
  542.  
  543. DEFUN ("current-local-map", Fcurrent_local_map, Scurrent_local_map, 0, 0, 0,
  544.   "Return current buffer's local keymap, or nil if it has none.")
  545.   ()
  546. {
  547.   return current_buffer->keymap;
  548. }
  549.  
  550. DEFUN ("current-global-map", Fcurrent_global_map, Scurrent_global_map, 0, 0, 0,
  551.   "Return the current global keymap.")
  552.   ()
  553. {
  554.   return global_map;
  555. }
  556.  
  557. DEFUN ("accessible-keymaps", Faccessible_keymaps, Saccessible_keymaps,
  558.   1, 1, 0,
  559.   "Find all keymaps accessible via prefix characters from KEYMAP.\n\
  560. Returns a list of elements of the form (KEYS . MAP), where the sequence\n\
  561. KEYS starting from KEYMAP gets you to MAP.  These elements are ordered\n\
  562. so that the KEYS increase in length.  The first element is (\"\" . KEYMAP).")
  563.   (startmap)
  564.      Lisp_Object startmap;
  565. {
  566.   Lisp_Object maps, tail;
  567.   register Lisp_Object thismap, thisseq;
  568.   register Lisp_Object dummy;
  569.   register Lisp_Object tem;
  570.   register Lisp_Object cmd;
  571.   register int i;
  572.  
  573.   maps = Fcons (Fcons (build_string (""), get_keymap (startmap)), Qnil);
  574.   tail = maps;
  575.  
  576.   /* For each map in the list maps,
  577.      look at any other maps it points to
  578.      and stick them at the end if they are not already in the list */
  579.  
  580.   while (!NULL (tail))
  581.     {
  582.       thisseq = Fcar (Fcar (tail));
  583.       thismap = Fcdr (Fcar (tail));
  584.       for (i = 0; i < 0200; i++)
  585.     {
  586.       cmd = get_keyelt (access_keymap (thismap, i));
  587.       if (NULL (cmd)) continue;
  588.       tem = Fkeymapp (cmd);
  589.       if (!NULL (tem))
  590.         {
  591.           cmd = get_keymap (cmd);
  592.           tem = Frassq (cmd, maps);
  593.           if (NULL (tem))
  594.         {
  595.           XFASTINT (dummy) = i;
  596.           dummy = concat2 (thisseq, Fchar_to_string (dummy));
  597.           nconc2 (tail, Fcons (Fcons (dummy, cmd), Qnil));
  598.         }
  599.         }
  600.     }
  601.       tail = Fcdr (tail);
  602.     }
  603.  
  604.   return maps;
  605. }
  606.  
  607. Lisp_Object Qsingle_key_description, Qkey_description;
  608.  
  609. DEFUN ("key-description", Fkey_description, Skey_description, 1, 1, 0,
  610.   "Return a pretty description of key-sequence KEYS.\n\
  611. Control characters turn into \"C-foo\" sequences, meta into \"M-foo\"\n\
  612. spaces are put between sequence elements, etc.")
  613.   (keys)
  614.      Lisp_Object keys;
  615. {
  616.   return Fmapconcat (Qsingle_key_description, keys, build_string (" "));
  617. }
  618.  
  619. char *
  620. push_key_description (c, p)
  621.      register unsigned int c;
  622.      register char *p;
  623. {
  624.   if (c >= 0200)
  625.     {
  626.       *p++ = 'M';
  627.       *p++ = '-';
  628.       c -= 0200;
  629.     }
  630.   if (c < 040)
  631.     {
  632.       if (c == 033)
  633.     {
  634.       *p++ = 'E';
  635.       *p++ = 'S';
  636.       *p++ = 'C';
  637.     }
  638.       else if (c == Ctl('I'))
  639.     {
  640.       *p++ = 'T';
  641.       *p++ = 'A';
  642.       *p++ = 'B';
  643.     }
  644.       else if (c == Ctl('J'))
  645.     {
  646.       *p++ = 'L';
  647.       *p++ = 'F';
  648.       *p++ = 'D';
  649.     }
  650.       else if (c == Ctl('M'))
  651.     {
  652.       *p++ = 'R';
  653.       *p++ = 'E';
  654.       *p++ = 'T';
  655.     }
  656.       else
  657.     {
  658.       *p++ = 'C';
  659.       *p++ = '-';
  660.       if (c > 0 && c <= Ctl ('Z'))
  661.         *p++ = c + 0140;
  662.       else
  663.         *p++ = c + 0100;
  664.     }
  665.     }
  666.   else if (c == 0177)
  667.     {
  668.       *p++ = 'D';
  669.       *p++ = 'E';
  670.       *p++ = 'L';
  671.     }
  672.   else if (c == ' ')
  673.     {
  674.       *p++ = 'S';
  675.       *p++ = 'P';
  676.       *p++ = 'C';
  677.     }
  678.   else
  679.     *p++ = c;
  680.   return p;  
  681. }
  682.  
  683. DEFUN ("single-key-description", Fsingle_key_description, Ssingle_key_description, 1, 1, 0,
  684.   "Return a pretty description of command character KEY.\n\
  685. Control characters turn into C-whatever, etc.")
  686.   (key)
  687.      Lisp_Object key;
  688. {
  689.   register unsigned char c;
  690.   char tem[6];
  691.  
  692.   CHECK_NUMBER (key, 0);
  693.   c = XINT (key) & 0377;
  694.  
  695.   *push_key_description (c, tem) = 0;
  696.  
  697.   return build_string (tem);
  698. }
  699.  
  700. char *
  701. push_text_char_description (c, p)
  702.      register unsigned int c;
  703.      register char *p;
  704. {
  705.   if (c >= 0200)
  706.     {
  707.       *p++ = 'M';
  708.       *p++ = '-';
  709.       c -= 0200;
  710.     }
  711.   if (c < 040)
  712.     {
  713.       *p++ = '^';
  714.       *p++ = c + 64;        /* 'A' - 1 */
  715.     }
  716.   else if (c == 0177)
  717.     {
  718.       *p++ = '^';
  719.       *p++ = '?';
  720.     }
  721.   else
  722.     *p++ = c;
  723.   return p;  
  724. }
  725.  
  726. DEFUN ("text-char-description", Ftext_char_description, Stext_char_description, 1, 1, 0,
  727.   "Return a pretty description of file-character CHAR.\n\
  728. Control characters turn into \"^char\", etc.")
  729.   (chr)
  730.      Lisp_Object chr;
  731. {
  732.   char tem[6];
  733.  
  734.   CHECK_NUMBER (chr, 0);
  735.  
  736.   *push_text_char_description (XINT (chr) & 0377, tem) = 0;
  737.  
  738.   return build_string (tem);
  739. }
  740.  
  741. DEFUN ("where-is-internal", Fwhere_is_internal, Swhere_is_internal, 1, 3, 0,
  742.   "Return list of key sequences that currently invoke command DEFINITION\n\
  743. in KEYMAP or (current-global-map).  If KEYMAP is nil, only search for\n\
  744. keys in the global map.\n\
  745. \n\
  746. If FIRSTONLY is non-nil, returns a string representing the first key\n\
  747. sequence found, rather than a list of all possible key sequences.")
  748.   (definition, local_keymap, firstonly)
  749.      Lisp_Object definition, local_keymap, firstonly;
  750. {
  751.   Lisp_Object start1;
  752.   register Lisp_Object maps;
  753.   Lisp_Object found;
  754.  
  755.   XSET (start1, Lisp_Vector, global_map);
  756.  
  757.   if (!NULL (local_keymap))
  758.     maps = nconc2 (Faccessible_keymaps (get_keymap (local_keymap)),
  759.            Faccessible_keymaps (start1));
  760.   else
  761.     maps = Faccessible_keymaps (start1);
  762.  
  763.   found = Qnil;
  764.  
  765.   for (; !NULL (maps); maps = Fcdr (maps))
  766.     {
  767.       register this = Fcar (Fcar (maps)); /* Key sequence to reach map */
  768.       register map = Fcdr (Fcar (maps)); /* The map that it reaches */
  769.       register int i = 0;
  770.      
  771.       if (CONSP (map))
  772.     map = Fcdr (map);
  773.  
  774.       /* If the MAP is a vector, I increments and eventually reaches 0200.
  775.      Otherwise I remains 0; MAP is cdr'd and eventually becomes nil.  */
  776.  
  777.       while (!NULL (map) && i < 0200)
  778.     {
  779.       register Lisp_Object elt, dummy;
  780.  
  781.       QUIT;
  782.       if (CONSP (map))
  783.         {
  784.           elt = Fcdr (Fcar (map));
  785.           dummy = Fcar (Fcar (map));
  786.           map = Fcdr (map);
  787.         }
  788.       else
  789.         {
  790.           elt = XVECTOR (map)->contents[i];
  791.           XFASTINT (dummy) = i;
  792.           i++;
  793.         }
  794.  
  795.       if (XTYPE (definition) != Lisp_Cons)
  796.         elt = get_keyelt (elt);
  797.  
  798.       /* End this iteration if this element does not match
  799.          the target.  */
  800.  
  801.       if (XTYPE (definition) == Lisp_Cons)
  802.         {
  803.           Lisp_Object tem;
  804.           tem = Fequal (elt, definition);
  805.           if (NULL (tem))
  806.         continue;
  807.         }
  808.       else
  809.         if (!EQ (elt, definition))
  810.           continue;
  811.  
  812.       /* We have found a match.
  813.          Construct the key sequence where we found it.  */
  814.  
  815.       dummy = concat2 (this, Fchar_to_string (dummy));
  816.  
  817.       /* Verify that this key binding is not shadowed
  818.          by another binding for the same key,
  819.          before we say it exists.
  820.          The mechanism: look for local definition of this key
  821.          and if it is defined and does not match what we found
  822.          then ignore this key.
  823.          Either nil or number as value from Flookup_key
  824.          means undefined.  */
  825.  
  826.       if (!NULL (local_keymap))
  827.         elt = Flookup_key (local_keymap, dummy);
  828.       if (!NULL (elt) && XTYPE (elt) != Lisp_Int)
  829.         {
  830.           if (XTYPE (definition) == Lisp_Cons)
  831.         {
  832.           Lisp_Object tem;
  833.           tem = Fequal (elt, definition);
  834.           if (NULL (tem))
  835.             continue;
  836.         }
  837.           else
  838.         if (!EQ (elt, definition))
  839.           continue;
  840.         }
  841.  
  842.       /* It is a true unshadowed match  Record it.  */
  843.  
  844.       if (!NULL (firstonly))
  845.         return dummy;
  846.       found = Fcons (dummy, found);
  847.     }
  848.     }
  849.   return Fnreverse (found);
  850. }
  851.  
  852. DEFUN ("where-is", Fwhere_is, Swhere_is, 1, 1, "CWhere is command: ",
  853.   "Print message listing key sequences that invoke specified command.\n\
  854. Argument is a command definition, usually a symbol with a function definition.")
  855.   (definition)
  856.      Lisp_Object definition;
  857. {
  858.   register Lisp_Object tem;
  859.   CHECK_SYMBOL (definition, 0);
  860.   tem = Fmapconcat (Qkey_description,
  861.             Fwhere_is_internal (definition, current_buffer->keymap, Qnil),
  862.             build_string (", "));
  863.   if (XSTRING (tem)->size)
  864.     message ("%s is on %s", XSYMBOL (definition)->name->data, XSTRING (tem)->data);
  865.   else
  866.     message ("%s is not on any keys", XSYMBOL (definition)->name->data);
  867.   return Qnil;
  868. }
  869.  
  870. Lisp_Object describe_buffer_bindings ();
  871.  
  872. DEFUN ("describe-bindings", Fdescribe_bindings, Sdescribe_bindings, 0, 0, "",
  873.   "Show a list of all defined keys, and their definitions.\n\
  874. The list is put in a buffer, which is displayed.")
  875.   ()
  876. {
  877.   register Lisp_Object thisbuf;
  878.   XSET (thisbuf, Lisp_Buffer, current_buffer);
  879.   internal_with_output_to_temp_buffer ("*Help*", describe_buffer_bindings, thisbuf);
  880.   return Qnil;
  881. }
  882.  
  883. Lisp_Object
  884. describe_buffer_bindings (descbuf)
  885.      Lisp_Object descbuf;
  886. {
  887.   register Lisp_Object start1;
  888.   char *heading = "key        binding\n---        -------\n";
  889.  
  890.   Fset_buffer (Vstandard_output);
  891.  
  892.   start1 = XBUFFER (descbuf)->keymap;
  893.   if (!NULL (start1))
  894.     {
  895.       InsStr ("Local Bindings:\n");
  896.       InsStr (heading);
  897.       heading = 0;
  898.       describe_map_tree (start1, 0, Qnil);
  899.       InsStr ("\n");
  900.     }
  901.  
  902.   InsStr ("Global Bindings:\n");
  903.   if (heading)
  904.     InsStr (heading);
  905.  
  906.   XSET (start1, Lisp_Vector, global_map);
  907.   describe_map_tree (start1, 0, XBUFFER (descbuf)->keymap);
  908.  
  909.   Fset_buffer (descbuf);
  910.   return Qnil;
  911. }
  912.  
  913. /* Insert a desription of the key bindings in STARTMAP,
  914.    followed by those of all maps reachable through STARTMAP.
  915.    If PARTIAL is nonzero, omit certain "uninteresting" commands
  916.    (such as `undefined').
  917.    If SHADOW is non-nil, don't mention keys which would be shadowed by it */
  918.  
  919. describe_map_tree (startmap, partial, shadow)
  920.      Lisp_Object startmap, shadow;
  921.      int partial;
  922. {
  923.   Lisp_Object maps;
  924.   register Lisp_Object elt, sh;
  925.   struct gcpro gcpro1;
  926.  
  927.   maps = Faccessible_keymaps (startmap);
  928.   GCPRO1 (maps);
  929.  
  930.   for (; !NULL (maps); maps = Fcdr (maps))
  931.     {
  932.       elt = Fcar (maps);
  933.       sh = Fcar (elt);
  934.       if (NULL (shadow))
  935.     sh = Qnil;
  936.       else if (XTYPE (sh) == Lisp_String &&
  937.            XSTRING (sh)->size == 0)
  938.     sh = shadow;
  939.       else
  940.     {
  941.       sh = Flookup_key (shadow, Fcar (elt));
  942.       if (XTYPE (sh) == Lisp_Int)
  943.         sh = Qnil;
  944.     }
  945.       if (NULL (sh) || !NULL (Fkeymapp (sh)))
  946.     describe_map (Fcdr (elt), Fcar (elt), partial, sh);
  947.     }
  948.  
  949.   UNGCPRO;
  950. }
  951.  
  952. describe_command (definition)
  953.      Lisp_Object definition;
  954. {
  955.   register Lisp_Object tem1;
  956.  
  957.   Findent_to (make_number (16), make_number (1));
  958.  
  959.   if (XTYPE (definition) == Lisp_Symbol)
  960.     {
  961.       XSET (tem1, Lisp_String, XSYMBOL (definition)->name);
  962.       insert1 (tem1);
  963.       InsStr ("\n");
  964.     }
  965.   else
  966.     {
  967.       tem1 = Fkeymapp (definition);
  968.       if (!NULL (tem1))
  969.     InsStr ("Prefix Command\n");
  970.       else
  971.     InsStr ("??\n");
  972.     }
  973. }
  974.  
  975. /* Describe the contents of map MAP, assuming that this map
  976.    itself is reached by the sequence of prefix keys STRING (a string).
  977.    PARTIAL and SHADOW are the same as in `describe_map_tree' above.  */
  978.  
  979. describe_map (map, string, partial, shadow)
  980.      Lisp_Object map, string;
  981.      int partial;
  982.      Lisp_Object shadow;
  983. {
  984.   register Lisp_Object keysdesc;
  985.  
  986.   if (!NULL (string) && XSTRING (string)->size > 0)
  987.     keysdesc = concat2 (Fkey_description (string), build_string (" "));
  988.   else
  989.     keysdesc = Qnil;
  990.  
  991.   if (CONSP (map))
  992.     describe_alist (Fcdr (map), keysdesc, describe_command,
  993.             partial, shadow);
  994.   else
  995.     describe_vector (map, keysdesc, describe_command,
  996.              partial, shadow);
  997. }
  998.  
  999. describe_alist (alist, elt_prefix, elt_describer, partial, shadow)
  1000.      register Lisp_Object alist;
  1001.      Lisp_Object elt_prefix;
  1002.      int (*elt_describer) ();
  1003.      int partial;
  1004.      Lisp_Object shadow;
  1005. {
  1006.   Lisp_Object this;
  1007.   Lisp_Object tem1, tem2;
  1008.   Lisp_Object suppress;
  1009.   Lisp_Object kludge = Qnil;
  1010.   int first = 1;
  1011.   struct gcpro gcpro1, gcpro2;
  1012.  
  1013.   if (partial)
  1014.     suppress = intern ("suppress-keymap");
  1015.  
  1016.   for (; CONSP (alist); alist = Fcdr (alist))
  1017.     {
  1018.       QUIT;
  1019.       tem1 = Fcar (Fcar (alist));
  1020.       tem2 = get_keyelt (Fcdr (Fcar (alist)));
  1021.       if (NULL (tem2)) continue;
  1022.       if (XTYPE (tem2) == Lisp_Symbol && partial)
  1023.     {
  1024.       this = Fget (tem2, suppress);
  1025.       if (!NULL (this))
  1026.         continue;
  1027.     }
  1028.  
  1029.       if (!NULL (shadow))
  1030.     {
  1031.       Lisp_Object tem;
  1032.       if (NULL (kludge)) kludge = build_string ("x");
  1033.       XSTRING (kludge)->data[0] = XINT (tem1);
  1034.       tem = Flookup_key (shadow, kludge);
  1035.       if (!NULL (tem)) continue;
  1036.     }
  1037.  
  1038.       if (first)
  1039.     {
  1040.       insert ("\n", 1);
  1041.       first = 0;
  1042.     }
  1043.  
  1044.       GCPRO2 (elt_prefix, tem2);
  1045.       if (!NULL (elt_prefix))
  1046.     insert1 (elt_prefix);
  1047.  
  1048.       insert1 (Fsingle_key_description (tem1));
  1049.  
  1050.       (*elt_describer) (tem2);
  1051.       UNGCPRO;
  1052.     }
  1053. }
  1054.  
  1055. describe_vector (vector, elt_prefix, elt_describer, partial, shadow)
  1056.      register Lisp_Object vector;
  1057.      Lisp_Object elt_prefix;
  1058.      int (*elt_describer) ();
  1059.      int partial;
  1060.      Lisp_Object shadow;
  1061. {
  1062.   Lisp_Object this;
  1063.   Lisp_Object dummy;
  1064.   Lisp_Object tem1, tem2;
  1065.   register int i, size = XVECTOR (vector)->size;
  1066.   Lisp_Object suppress;
  1067.   Lisp_Object kludge;
  1068.   int first = 1;
  1069.   struct gcpro gcpro1, gcpro2;
  1070.  
  1071.   tem1 = Qnil;
  1072.   kludge = Qnil;
  1073.   GCPRO2 (elt_prefix, tem1);
  1074.  
  1075.   if (partial)
  1076.     suppress = intern ("suppress-keymap");
  1077.  
  1078.   for (i = 0; i < size; i++)
  1079.     {
  1080.       QUIT;
  1081.       tem1 = get_keyelt (XVECTOR (vector)->contents[i]);
  1082.       if (NULL (tem1)) continue;      
  1083.       if (XTYPE (tem1) == Lisp_Symbol && partial)
  1084.     {
  1085.       this = Fget (tem1, suppress);
  1086.       if (!NULL (this))
  1087.         continue;
  1088.     }
  1089.  
  1090.       if (!NULL (shadow))
  1091.     {
  1092.       Lisp_Object tem;
  1093.       if (NULL (kludge)) kludge = build_string ("x");
  1094.       XSTRING (kludge)->data[0] = XINT (i);
  1095.       tem = Flookup_key (shadow, kludge);
  1096.       if (!NULL (tem)) continue;
  1097.     }
  1098.  
  1099.       if (first)
  1100.     {
  1101.       insert ("\n", 1);
  1102.       first = 0;
  1103.     }
  1104.  
  1105.       if (!NULL (elt_prefix))
  1106.     insert1 (elt_prefix);
  1107.  
  1108.       XFASTINT (dummy) = i;
  1109.       insert1 (Fsingle_key_description (dummy));
  1110.  
  1111.       while (i + 1 < size
  1112.          && (tem2 = get_keyelt (XVECTOR (vector)->contents[i+1]),
  1113.          EQ (tem2, tem1)))
  1114.     i++;
  1115.  
  1116.       if (i != XINT (dummy))
  1117.     {
  1118.       insert (" .. ", 4);
  1119.       if (!NULL (elt_prefix))
  1120.         insert1 (elt_prefix);
  1121.  
  1122.       XFASTINT (dummy) = i;
  1123.       insert1 (Fsingle_key_description (dummy));
  1124.     }
  1125.  
  1126.       (*elt_describer) (tem1);
  1127.     }
  1128.  
  1129.   UNGCPRO;
  1130. }
  1131.  
  1132. /* Apropos */
  1133. Lisp_Object apropos_predicate;
  1134. Lisp_Object apropos_accumulate;
  1135.  
  1136. static
  1137. apropos_accum (symbol, string)
  1138.      Lisp_Object symbol, string;
  1139. {
  1140.   register Lisp_Object tem;
  1141.  
  1142.   tem = Fstring_match (string, Fsymbol_name (symbol), Qnil);
  1143.   if (!NULL (tem) && !NULL (apropos_predicate))
  1144.     tem = call1 (apropos_predicate, symbol);
  1145.   if (!NULL (tem))
  1146.     apropos_accumulate = Fcons (symbol, apropos_accumulate);
  1147. }
  1148.  
  1149. static Lisp_Object
  1150. apropos1 (list)
  1151.      register Lisp_Object list;
  1152. {
  1153.   struct buffer *old = current_buffer;
  1154.   register Lisp_Object symbol, col, tem;
  1155.  
  1156.   while (!NULL (list))
  1157.     {
  1158.       Lisp_Object min_cols;
  1159.  
  1160.       QUIT;
  1161.  
  1162.       symbol = Fcar (list);
  1163.       list = Fcdr (list);
  1164.  
  1165.       tem = Fwhere_is_internal (symbol, current_buffer->keymap, Qnil);
  1166.       tem = Fmapconcat (Qkey_description, tem, build_string (", "));
  1167.       XFASTINT (col) = 30;
  1168.  
  1169.       set_buffer_internal (XBUFFER (Vstandard_output));
  1170.       Fprin1 (symbol, Qnil);
  1171.       XFASTINT (min_cols) = 1;
  1172.       Findent_to (col, min_cols);
  1173.       Fprinc (tem, Qnil);
  1174.       Fterpri (Qnil);
  1175.       tem = Ffboundp (symbol);
  1176.       if (!NULL (tem))
  1177.         tem = Fdocumentation (symbol);
  1178.       if (XTYPE (tem) == Lisp_String)
  1179.     insert_first_line ("  Function: ", tem);
  1180.       tem = Fdocumentation_property (symbol, Qvariable_documentation);
  1181.       if (XTYPE (tem) == Lisp_String)
  1182.     insert_first_line ("  Variable: ", tem);
  1183.       set_buffer_internal (old);
  1184.     }
  1185.   return Qnil;
  1186. }
  1187.  
  1188. static void
  1189. insert_first_line (prefix, str)
  1190.      char *prefix;
  1191.      Lisp_Object str;
  1192. {
  1193.   extern char *index ();
  1194.   register unsigned char *p;
  1195.   register unsigned char *p1;
  1196.   register unsigned char *p2;
  1197.   struct gcpro gcpro1;
  1198.  
  1199.   GCPRO1 (str);
  1200.   InsStr (prefix);
  1201.  
  1202.  retry:
  1203.   p = XSTRING (str)->data;
  1204.   p1 = (unsigned char *) index (p, '\n');
  1205.  
  1206.   for (p2 = p; *p2 && p2 != p1; p2++)
  1207.     if (p2[0] == '\\' && p2[1] == '[')
  1208.       {
  1209.     str = Fsubstitute_command_keys (str);
  1210.     goto retry;
  1211.       }
  1212.  
  1213.   insert (p, p1 ? p1 - p : strlen (p));
  1214.   insert ("\n", 1);
  1215.   UNGCPRO;
  1216. }
  1217.  
  1218. DEFUN ("apropos", Fapropos, Sapropos, 1, 3, "sApropos: ",
  1219.   "Show all symbols whose names contain match for REGEXP.\n\
  1220. If optional arg PRED is non-nil, (funcall PRED SYM) is done\n\
  1221. for each symbol and a symbol is mentioned if that returns non-nil.\n\
  1222. Returns list of symbols found; if third arg NOPRINT is non-nil,\n\
  1223. does not display them, just returns the list.")
  1224.   (string, pred, noprint)
  1225.      Lisp_Object string, pred, noprint;
  1226. {
  1227.   struct gcpro gcpro1, gcpro2;
  1228.   CHECK_STRING (string, 0);
  1229.   apropos_predicate = pred;
  1230.   GCPRO2 (apropos_predicate, apropos_accumulate);
  1231.   apropos_accumulate = Qnil;
  1232.   map_obarray (Vobarray, apropos_accum, string);
  1233.   apropos_accumulate = Fsort (apropos_accumulate, Qstring_lessp);
  1234.   if (NULL (noprint))
  1235.     internal_with_output_to_temp_buffer ("*Help*", apropos1,
  1236.                      apropos_accumulate);
  1237.   UNGCPRO;
  1238.   return apropos_accumulate;
  1239. }
  1240.  
  1241. syms_of_keymap ()
  1242. {
  1243.   Lisp_Object tem;
  1244.  
  1245.   Qkeymap = intern ("keymap");
  1246.   staticpro (&Qkeymap);
  1247.  
  1248. /* Initialize the keymaps standardly used.
  1249.    Each one is the value of a Lisp variable, and is also
  1250.    pointed to by a C variable */
  1251.  
  1252. #ifdef HAVE_X_WINDOWS
  1253.   tem = Fmake_keymap ();
  1254.   MouseMap = tem;
  1255.   Fset (intern ("mouse-map"), tem);
  1256. #endif /* HAVE_X_WINDOWS */
  1257.  
  1258.   tem = Fmake_keymap ();
  1259.   Vglobal_map = tem;
  1260.   Fset (intern ("global-map"), tem);
  1261.  
  1262.   tem = Fmake_keymap ();
  1263.   Vesc_map = tem;
  1264.   Fset (intern ("esc-map"), tem);
  1265.   Ffset (intern ("ESC-prefix"), tem);
  1266.  
  1267.   tem = Fmake_keymap ();
  1268.   Vctl_x_map = tem;
  1269.   Fset (intern ("ctl-x-map"), tem);
  1270.   Ffset (intern ("Control-X-prefix"), tem);
  1271.  
  1272.   DEFVAR_LISP ("minibuffer-local-map", &Vminibuffer_local_map,
  1273.     "Default keymap to use when reading from the minibuffer.");
  1274.   Vminibuffer_local_map = Fmake_sparse_keymap ();
  1275.  
  1276.   DEFVAR_LISP ("minibuffer-local-ns-map", &Vminibuffer_local_ns_map,
  1277.     "The keymap used by the minibuf for local bindings when spaces are not\n\
  1278. to be allowed in input string.");
  1279.   Vminibuffer_local_ns_map = Fmake_sparse_keymap ();
  1280.  
  1281.   DEFVAR_LISP ("minibuffer-local-completion-map", &Vminibuffer_local_completion_map,
  1282.     "Keymap to use when reading from the minibuffer with completion.");
  1283.   Vminibuffer_local_completion_map = Fmake_sparse_keymap ();
  1284.  
  1285.   DEFVAR_LISP ("minibuffer-local-must-match-map", &Vminibuffer_local_must_match_map,
  1286.     "Keymap to use when reading from the minibuffer with completion and\n\
  1287. an exact match of one of the completions is required.");
  1288.   Vminibuffer_local_must_match_map = Fmake_sparse_keymap ();
  1289.  
  1290.   global_map = Vglobal_map;
  1291.  
  1292.   Qsingle_key_description = intern ("single-key-description");
  1293.   staticpro (&Qsingle_key_description);
  1294.  
  1295.   Qkey_description = intern ("key-description");
  1296.   staticpro (&Qkey_description);
  1297.  
  1298.   Qkeymapp = intern ("keymapp");
  1299.   staticpro (&Qkeymapp);
  1300.  
  1301.   defsubr (&Skeymapp);
  1302.   defsubr (&Smake_keymap);
  1303.   defsubr (&Smake_sparse_keymap);
  1304.   defsubr (&Scopy_keymap);
  1305.   defsubr (&Skey_binding);
  1306.   defsubr (&Slocal_key_binding);
  1307.   defsubr (&Sglobal_key_binding);
  1308.   defsubr (&Sglobal_set_key);
  1309.   defsubr (&Slocal_set_key);
  1310.   defsubr (&Sdefine_key);
  1311.   defsubr (&Slookup_key);
  1312.   defsubr (&Sglobal_unset_key);
  1313.   defsubr (&Slocal_unset_key);
  1314.   defsubr (&Sdefine_prefix_command);
  1315.   defsubr (&Suse_global_map);
  1316.   defsubr (&Suse_local_map);
  1317.   defsubr (&Scurrent_local_map);
  1318.   defsubr (&Scurrent_global_map);
  1319.   defsubr (&Saccessible_keymaps);
  1320.   defsubr (&Skey_description);
  1321.   defsubr (&Ssingle_key_description);
  1322.   defsubr (&Stext_char_description);
  1323.   defsubr (&Swhere_is_internal);
  1324.   defsubr (&Swhere_is);
  1325.   defsubr (&Sdescribe_bindings);
  1326.   defsubr (&Sapropos);
  1327. }
  1328.  
  1329. keys_of_keymap ()
  1330. {
  1331.   ndefkey (Vglobal_map, 033, "ESC-prefix");
  1332.   ndefkey (Vglobal_map, Ctl ('X'), "Control-X-prefix");
  1333. }
  1334.